<?php
require_once 'conexao.php';
?>
<html>
    <body>
        <table align="left" border="1" cellpadding="1" cellspacing="1" style="width: 1210px; height: 93px;">

            <tr>
                <td style="width: 200px; height: 70px;">
                    <img alt="" src="http://www.saoexpedito.com.br/imagens/logo.jpg" style="width: 201px; height: 70px;" /></td>
                <td style="text-align: center;"><h1>CONTROLE DE SAÍDA - PRESTADOR</h1></td>
                <td style="width: 150px;">
                    Rev.: 00<br />
                    Data: 17/05/2010<br />
                    P&aacute;gina 1 de 1</td>
            </tr>

        </table> 
        <p>
            <?php
            $datas = explode('/', $_POST['dt_entrada_ini']);
            $datade = $datas['2'] . "-" . $datas['1'] . "-" . $datas['0'];
            $datas = explode('/', $_POST['dt_entrada_fim']);
            $dataate = $datas['2'] . "-" . $datas['1'] . "-" . $datas['0'];
            $sql = "SELECT * FROM prestador WHERE dt_saida >='" . $datade . "' AND dt_saida <= '" . $dataate . "'";

            if ($_POST['placa'] <> 'TODOS') {
                $sql = $sql . " and placa = '" . $_POST['placa'] . "'";
            }
            if ($_POST['motorista'] <> 'TODOS') {
                $sql = $sql . " and motorista = '" . $_POST['motorista'] . "'";
            }
            if ($_POST['operacao'] <> 'TODOS') {
                $sql = $sql . " and operacao = '" . $_POST['operacao'] . "'";
            }
            if ($_POST['destino'] <> 'TODOS') {
                $sql = $sql . " and destino = '" . $_POST['destino'] . "'";
            }

            $result = mysql_query($sql);
            ?>
        </p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <table width="1210" border="0" name="tabela_rel">
            <tr style="background-color: lightgray; font-weight: bold">
                <td width="106" align="center">DATA</td>
                <td width="363" align="center">MOTORISTA</td>
                <td width="124" align="center">HORARIO</td>
                <td width="193" align="center">DESTINO</td>
                <td width="78" align="center">CAPACETE Nº</td>
                <td width="101" align="center">CRACHÁ</td>
                <td width="198" align="center">PLACA</td>
                <td width="198" align="center">USUÁRIO</td>
            </tr>
            <?php
            echo mysql_error();
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $datas = explode('-', $row['dt_entrada']);
                $datade = $datas['2'] . "/" . $datas['1'] . "/" . $datas['0'];
                echo"<tr>
            <td align='center' valign='middle' style='border-bottom: 1px solid black'>" . ($datade) .
                "</td>
            <td align='center' valign='middle' style='border-bottom: 1px solid black'>" . ($row['motorista']) .
                "</td>
            <td align='center' valign='middle' style='border-bottom: 1px solid black'>" . $row['hr_entrada'] .
                "</td>
            <td align='center' valign='middle' style='border-bottom: 1px solid black'>" . $row['destino'] .
                "</td>
            <td align='center' valign='middle' style='border-bottom: 1px solid black'>" . $row['capacete'] .
                "</td>
            <td align='center' valign='middle' style='border-bottom: 1px solid black'>" . $row['cracha'] .
                "</td>
            <td align='center' valign='middle' style='border-bottom: 1px solid black'>" . $row['placa'] .
                "</td>
            <td align='center' valign='middle' style='border-bottom: 1px solid black'>" . $row['port_saida'] .
                "</td>       
                    </tr>";
            }
            ?>
        </table>
    </body>
</html>